<?php

/**
 * Description of sort
 * 
 * @author 叶风
 * Qq:    355007778
 * Email: ye.fn@163.com
 */

namespace c\goods\sort;

class v extends \control
{
    use \m\tree_g;

    var $table = 'goods_sort';
    var $State = array('hide', 'publish');

    function index_home()
    {
        $id = intval($_GET['id']);
        if ($id)
         {
            $d = $this->getOne($id);
            $this->isExist($d);
            if ($d['layout_id']) 
                $this->loadLayout($d['layout_id']);
            else{
                $_POST['id'] = '';
                $_POST['sid'] = $id;
                (new \out())->parseParams('u=cgoods\search')->go();
                die;
             }
         }
        else {
            $res = $this->getParent(0, -1);
            $this->loadTemplate('goods/allSort', array('res'=>$res));
            $this->display('lb_r');
         }
    }

    function li($ids)
    {
        return $this->db->get($this->table, '*', "id IN($ids) AND state>0");
    }
}
